Page({
  data: {
    followCount: 3, 
    followItems: [
      { id: 1, avatarUrl: '/images/course/demo1.jpg', name: '同程旅行', followed: true },
      { id: 2, avatarUrl: '/images/course/demo1.jpg', name: '小猪干饭日记', followed: true },
      { id: 3, avatarUrl: '/images/course/demo1.jpg', name: '小红薯6683DCF1', followed: true },
    ],
  },

  handleToggleFollow(e) {
    const { id } = e.currentTarget.dataset;
    const items = this.data.followItems.map(item => {
      if (item.id === id) {
        item.followed = !item.followed;
      }
      return item;
    });
    const followCount = items.filter(item => item.followed).length;
    this.setData({ followItems: items, followCount });
  }
});
